package com.linghang.demo.controller;

import com.linghang.demo.domain.WustDown;

import com.linghang.demo.req.WustdownQueryReq;
import com.linghang.demo.resp.CommonResp;
import com.linghang.demo.resp.PageResp;

import com.linghang.demo.resp.WustdownQueryResp;


import com.linghang.demo.service.WustdownService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

//武科大下载
@RestController
@RequestMapping ("/wustdown")
public class WustdownController {


    @Resource
    private WustdownService wustdownService;


    @GetMapping("/list1")
    public CommonResp list() {
        CommonResp<List<WustDown>> resp = new CommonResp<>();
        List<WustDown> list =  wustdownService.list();
        resp.setContent(list);
        return resp;
    }
    @GetMapping("/list")
    public CommonResp list(@Valid WustdownQueryReq req) {
        CommonResp<PageResp<WustdownQueryResp>> resp = new CommonResp<>();
        PageResp<WustdownQueryResp> list = wustdownService.list(req);
        resp.setContent(list);
        return resp;
    }

    @DeleteMapping("/delete/{id}")
    public CommonResp delete(@PathVariable int id){
        CommonResp resp=new CommonResp<>();
        wustdownService.delete(id);

        return resp;
    }

    @PostMapping("/save")
    public CommonResp save(@Valid @RequestBody WustdownQueryReq req) {
        CommonResp resp = new CommonResp<>();
        wustdownService.save(req);
        return resp;
    }
}